
var go = setInterval("loop()",500);
function loop() {
    oDiv.addEventListener("click", add);
}

function setAlpha(iTarget){ //iTarget目标透明度通过参数传入
    clearInterval(timer);
    timer=setInterval(function(){
        var iSpeed;
        if(alpha<iTarget)
        {
            iSpeed=10;
        }
        else
        {
            iSpeed=-10;
        }
        if(alpha==iTarget)
        {
            clearInterval(timer);
        }
        else
        {
            alpha+=iSpeed;
            dDiv.style.opacity=alpha/100;
            dDiv.style.filter='alpha(opacity:'+alpha+')'
        }
    },50);
};

function add() {
    if(dDiv.style.opacity>0)
        setAlpha(0);
    else setAlpha(100);
}